import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yi_shop/utils/colors.dart';
import 'package:yi_shop/utils/styles.dart';
import 'package:yi_shop/utils/svg.dart';
import 'package:yi_shop/utils/tools.dart';

class InvoiceIssueController extends GetxController {
  RxBool isCorpuscle = RxBool(true);
}

class InvoiceIssuePage extends GetView<InvoiceIssueController> {
  const InvoiceIssuePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        leading: ToolsUtils.builderLeading(),
        title: Text(
          '开具发票',
          style: StylesUtils.customTextStyle(
              fontWeight: FontWeight.w700, fontSize: StylesUtils.fontSize18),
        ),
        elevation: 1,
        shadowColor: ColorsUtils.rgba(242, 242, 242, 1),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Container(
              color: Colors.white,
              child: Column(
                children: [
                  Container(
                    padding: EdgeInsets.symmetric(horizontal: 15.w),
                    height: 50,
                    alignment: Alignment.centerLeft,
                    child: Text(
                      '发票类型',
                      style: StylesUtils.customTextStyle(color: ColorsUtils.color3333),
                    ),
                  ),
                  Container(
                    padding: EdgeInsets.symmetric(horizontal: 15.w),
                    child: Row(
                      children: [
                        Expanded(
                            child: Align(
                          alignment: Alignment.centerLeft,
                          child: Obx(() => TextButton(
                              onPressed: () {
                                controller.isCorpuscle.value = true;
                              },
                              style: ButtonStyle(
                                  alignment: Alignment.center,
                                  fixedSize: const MaterialStatePropertyAll(Size(135, 40)),
                                  shape: MaterialStatePropertyAll(RoundedRectangleBorder(
                                      borderRadius: BorderRadius.circular(5.r),
                                      side: BorderSide(
                                          color: controller.isCorpuscle.isTrue
                                              ? ColorsUtils.parseColorFromHexString(
                                                  ColorsUtils.colorF048)
                                              : ColorsUtils.parseColorFromHexString(
                                                  ColorsUtils.color9999))))),
                              child: Text(
                                '电子普通发票',
                                style: StylesUtils.customTextStyle(
                                    fontSize: StylesUtils.fontSize13,
                                    color: controller.isCorpuscle.isTrue
                                        ? ColorsUtils.colorF048
                                        : ColorsUtils.color3333),
                              ))),
                        )),
                        Expanded(
                            child: Align(
                                alignment: Alignment.centerLeft,
                                child: Obx(
                                  () => TextButton(
                                      onPressed: () {
                                        controller.isCorpuscle.value = false;
                                      },
                                      style: ButtonStyle(
                                          alignment: Alignment.center,
                                          fixedSize: const MaterialStatePropertyAll(Size(135, 40)),
                                          shape: MaterialStatePropertyAll(RoundedRectangleBorder(
                                              borderRadius: BorderRadius.circular(5.r),
                                              side: BorderSide(
                                                  color: controller.isCorpuscle.isFalse
                                                      ? ColorsUtils.parseColorFromHexString(
                                                          ColorsUtils.colorF048)
                                                      : ColorsUtils.parseColorFromHexString(
                                                          ColorsUtils.color9999))))),
                                      child: Text('纸质普通发票',
                                          style: StylesUtils.customTextStyle(
                                              fontSize: StylesUtils.fontSize13,
                                              color: controller.isCorpuscle.isFalse
                                                  ? ColorsUtils.colorF048
                                                  : ColorsUtils.color3333))),
                                )))
                      ],
                    ),
                  ),
                  Container(
                    padding: EdgeInsets.only(top: 20, bottom: 15, left: 15.w, right: 15.w),
                    alignment: Alignment.centerLeft,
                    child: Text(
                      '电子发票即电子增值税发票，是税务局认可的有效凭证，其法律效力、基本用途及使用规定同纸质发票。',
                      style: StylesUtils.customTextStyle(
                          color: ColorsUtils.color9999,
                          fontSize: StylesUtils.fontSize13,
                          lineHeight: 1.4.h),
                    ),
                  )
                ],
              ),
            ),
            Container(
              margin: const EdgeInsets.only(top: 20),
              color: Colors.white,
              child: Column(
                children: [
                  Container(
                    height: 50,
                    padding: EdgeInsets.symmetric(horizontal: 15.w),
                    decoration: BoxDecoration(
                        border: Border(
                            bottom: BorderSide(
                                color:
                                    ColorsUtils.parseColorFromHexString(ColorsUtils.colorF2f2)))),
                    alignment: Alignment.centerLeft,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(
                          '发票抬头',
                          style: StylesUtils.customTextStyle(color: ColorsUtils.color6666),
                        ),
                        Wrap(
                          spacing: 15,
                          crossAxisAlignment: WrapCrossAlignment.center,
                          alignment: WrapAlignment.end,
                          children: [
                            Text(
                              '个人',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color6666),
                            ),
                            SvgUtils.assetName('u10437', width: 20, height: 20)
                          ],
                        )
                      ],
                    ),
                  ),
                  Container(
                    height: 50,
                    padding: EdgeInsets.symmetric(horizontal: 15.w),
                    alignment: Alignment.centerLeft,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(
                          '发票内容',
                          style: StylesUtils.customTextStyle(color: ColorsUtils.color6666),
                        ),
                        Wrap(
                          spacing: 15,
                          crossAxisAlignment: WrapCrossAlignment.center,
                          alignment: WrapAlignment.end,
                          children: [
                            Text(
                              '个人',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color6666),
                            ),
                            Icon(
                              Icons.arrow_forward_ios,
                              color: ColorsUtils.parseColorFromHexString(ColorsUtils.color9999),
                              size: 15,
                            )
                          ],
                        )
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Obx(() => Visibility(
                visible: controller.isCorpuscle.isTrue,
                child: Container(
                  margin: const EdgeInsets.only(top: 20),
                  color: Colors.white,
                  child: Column(
                    children: [
                      Container(
                        height: 50,
                        padding: EdgeInsets.symmetric(horizontal: 15.w),
                        decoration: BoxDecoration(
                            border: Border(
                                bottom: BorderSide(
                                    color: ColorsUtils.parseColorFromHexString(
                                        ColorsUtils.colorF2f2)))),
                        alignment: Alignment.centerLeft,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text(
                              '收票人手机',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color6666),
                            ),
                            Text(
                              '135*****0147',
                              style: StylesUtils.customTextStyle(
                                  color: ColorsUtils.color3333, fontSize: StylesUtils.fontSize13),
                            ),
                          ],
                        ),
                      ),
                      Container(
                        height: 50,
                        padding: EdgeInsets.symmetric(horizontal: 15.w),
                        alignment: Alignment.centerLeft,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text(
                              '收票人邮箱',
                              style: StylesUtils.customTextStyle(color: ColorsUtils.color6666),
                            ),
                            Text(
                              '267975828@qq.com',
                              style: StylesUtils.customTextStyle(
                                  color: ColorsUtils.color3333, fontSize: StylesUtils.fontSize13),
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ))),
            Container(
              margin: const EdgeInsets.only(top: 30),
              alignment: Alignment.center,
              child: TextButton(
                  onPressed: () {},
                  style: ButtonStyle(
                      alignment: Alignment.center,
                      fixedSize: MaterialStatePropertyAll(Size(300.w, 45)),
                      backgroundColor: MaterialStatePropertyAll(
                          ColorsUtils.parseColorFromHexString(ColorsUtils.colorF048)),
                      shape: MaterialStatePropertyAll(
                          RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.r)))),
                  child: Text(
                    '保存',
                    style: StylesUtils.customTextStyle(),
                  )),
            ),
            Container(
              padding: EdgeInsets.symmetric(horizontal: 15.w),
              margin: const EdgeInsets.only(top: 30, bottom: 30),
              child: Column(
                children: [
                  Container(
                    alignment: Alignment.centerLeft,
                    child: RichText(
                      text: TextSpan(children: [
                        WidgetSpan(child: SvgUtils.assetName('u17687', width: 15, height: 15)),
                        TextSpan(
                            text: '  发票需知',
                            style: StylesUtils.customTextStyle(color: ColorsUtils.color9999))
                      ]),
                    ),
                  ),
                  Container(
                    margin: const EdgeInsets.only(top: 10),
                    alignment: Alignment.centerLeft,
                    child: Text(
                      '1.开票金额为用户实际支付金额（不含礼品卡）',
                      style: StylesUtils.customTextStyle(
                          color: ColorsUtils.color9999, lineHeight: 1.4.h),
                    ),
                  ),
                  Container(
                    margin: const EdgeInsets.only(top: 10),
                    alignment: Alignment.centerLeft,
                    child: Text(
                      '2.电子发票可在确认收货后，在“订单详情”查看',
                      style: StylesUtils.customTextStyle(
                          color: ColorsUtils.color9999, lineHeight: 1.4.h),
                    ),
                  ),
                  Container(
                    margin: const EdgeInsets.only(top: 10),
                    alignment: Alignment.centerLeft,
                    child: Text(
                      '3.未随箱寄出的纸质发票会在发货后15-30个工作日单独寄出',
                      style: StylesUtils.customTextStyle(
                          color: ColorsUtils.color9999, lineHeight: 1.4.h),
                    ),
                  ),
                  Container(
                    margin: const EdgeInsets.only(top: 10),
                    alignment: Alignment.centerLeft,
                    child: Text(
                      '4.单笔订单只支持开具一种发票类型，如需增值税专用发票请联系客服处理',
                      style: StylesUtils.customTextStyle(
                          color: ColorsUtils.color9999, lineHeight: 1.4.h),
                    ),
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}
